extends ../layout

include ./admin-mixins.pug

block headContent
	title App Stats

block content
	+adminNav("App Stats")


	+pageTitle("App Stats")

	+contentSection("Performance Stats")
		.table-responsive
			table.table.table-borderless.table-striped
				thead
					tr
						th Name
						th.text-end Min
						th.text-end Avg
						th.text-end Max
						th.text-end Sum
						th.text-end Count
						th.text-end First
						th.text-end Latest

				tbody
					each item, itemIndex in performanceStats
						tr
							td #{item[0]}
							td.text-end #{Math.round(item[1].min).toLocaleString()}
							td.text-end #{Math.round(item[1].avg).toLocaleString()}
							td.text-end #{Math.round(item[1].max).toLocaleString()}
							td.text-end #{Math.round(item[1].sum).toLocaleString()}
							td.text-end #{Math.round(item[1].count).toLocaleString()}
							td.text-end
								- var dt = moment.duration(new Date().getTime() - item[1].firstDate.getTime());
								span #{dt.format()}
							td.text-end
								- var dt = moment.duration(new Date().getTime() - item[1].lastDate.getTime());
								span #{dt.format()}


	+contentSection("Event Stats")
		.table-responsive
			table.table.table-borderless.table-striped
				thead
					tr
						th Name
						th.text-end Count

				tbody
					each item, itemIndex in eventStats
						tr
							td #{item[0]}
							td.text-end #{item[1].toLocaleString()}


	+contentSection("Value Stats")
		.table-responsive
			table.table.table-borderless.table-striped
				thead
					tr
						th Name
						th.text-end Min
						th.text-end Avg
						th.text-end Max
						th.text-end Sum
						th.text-end Count
						th.text-end First
						th.text-end Latest

				tbody
					each item, itemIndex in valueStats
						tr
							td #{item[0]}
							td.text-end #{Math.round(item[1].min).toLocaleString()}
							td.text-end #{Math.round(item[1].avg).toLocaleString()}
							td.text-end #{Math.round(item[1].max).toLocaleString()}
							td.text-end #{Math.round(item[1].sum).toLocaleString()}
							td.text-end #{Math.round(item[1].count).toLocaleString()}
							td.text-end
								- var dt = moment.duration(new Date().getTime() - item[1].firstDate.getTime());
								span #{dt.format()}
							td.text-end
								- var dt = moment.duration(new Date().getTime() - item[1].lastDate.getTime());
								span #{dt.format()}
